﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Beetle.Sl.EditorControl.Core;

namespace Beetle.Sl.EditorControl.ToolBars.ReadOnly
{
    [ToolBarItemAttribute]
    public class EditorStatusToolBar : ToolBarItem
    {
        private const string COMMANDTEXT = "EditorStatus";
        private Uri isReadOnlyUri = new Uri("/Beetle.Sl.EditorControl;component/ToolBars/EditorStatus/Designer.png", UriKind.Relative);
        private Uri canEditUri = new Uri("/Beetle.Sl.EditorControl;component/ToolBars/EditorStatus/Edit.png", UriKind.Relative);

        public EditorStatusToolBar()
        {
            this.ImageButtonUri = this.isReadOnlyUri;
        }

        public override string Name
        {
            get
            {
                return "EditorStatus";
            }
        }

        public override void OnCommand(object arg)
        {
            this.Editor.ExcuteCommand(EditorStatusToolBar.COMMANDTEXT, arg);
        }

        public override void UpdateVisual()
        {
            if (this.Editor.RichTextBoxInst.IsReadOnly)
            {
                this.ImageButtonUri = this.canEditUri;
                this.IsSelected = true;
            }
            else
            {
                this.ImageButtonUri = this.isReadOnlyUri;
                this.IsSelected = false;
            }
        }
    }
}
